import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:fzcgx_app/common/adapter_utils.dart';
import 'package:fzcgx_app/common/assets_utils.dart';
import 'package:fzcgx_app/network/http.dart';
import 'package:fzcgx_app/router/routes.dart';
import 'package:fzcgx_app/ui/my/worker/page/worker_certificates_page.dart';
import 'package:fzcgx_app/ui/my/worker/page/worker_base_info_page.dart';
import 'package:fzcgx_app/ui/my/worker/page/worker_expe_page.dart';
import 'package:fzcgx_app/ui/my/worker/page/worker_education_background_page.dart';
import 'package:fzcgx_app/ui/my/worker/page/worker_family_page.dart';
import 'package:fzcgx_app/ui/my/worker/page/worker_object_company_page.dart';
import 'package:fzcgx_app/ui/my/worker/page/worker_object_factory_page.dart';
import 'package:fzcgx_app/ui/my/worker/page/worker_evaluate_page.dart';
import 'package:fzcgx_app/ui/widget/custom_appbar_widget.dart';
 
class WorkerPage extends StatefulWidget {
  WorkerPage({Key key}) : super(key: key);

  @override
  _WorkerPageState createState() => _WorkerPageState();
}

class _WorkerPageState extends State<WorkerPage> {
  Map data;
  @override
  void initState() {
    requestApi();
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.white,
      appBar: CustomAppbar(
        title: '个人资料完善',
      ),
      body: SafeArea(
          child: data == null
              ? _loadingWidget()
              : SingleChildScrollView(
                  child: Column(
                    children: <Widget>[
                      InkWell(
                        onTap: () {
                          Routes.navigateTo(context, WorkerBaseInfoPage());
                        },
                        child: Container(
                          margin:
                              EdgeInsets.only(left: AdapterUtils.getWidth(20)),
                          height: AdapterUtils.getHeight(80),
                          decoration: BoxDecoration(
                              border: Border(
                                  bottom: BorderSide(
                                      color: Color(0xffEEEEEE), width: 1))),
                          child: Row(
                            mainAxisAlignment: MainAxisAlignment.spaceBetween,
                            children: <Widget>[
                              Row(
                                children: <Widget>[
                                  Text(
                                    '基本信息',
                                    style: TextStyle(
                                      fontSize: AdapterUtils.getSp(16),
                                      color: Color(0xff141F33),
                                      fontWeight: FontWeight.w500,
                                    ),
                                  ),
                                  Text(
                                    ' *',
                                    style: TextStyle(
                                      fontSize: AdapterUtils.getSp(16),
                                      color: Color(0xffFF1515),
                                      fontWeight: FontWeight.w500,
                                    ),
                                  ),
                                ],
                              ),
                              Row(
                                children: <Widget>[
                                  Text(
                                  data['isbase']==1?'已上传' :'请上传',
                                    style: TextStyle(
                                      fontSize: AdapterUtils.getSp(14),
                                      color: Color(0xffD7D8DB),
                                      fontWeight: FontWeight.w500,
                                    ),
                                  ),
                                  SizedBox(
                                    width: AdapterUtils.getWidth(20),
                                  ),
                                  Image.asset(AssetsUtils.getAssetsImagesPath(
                                      'arrow_right.png')),
                                  SizedBox(
                                    width: AdapterUtils.getWidth(20),
                                  )
                                ],
                              )
                            ],
                          ),
                        ),
                      ),
                      InkWell(
                        onTap: (){
                           Routes.navigateTo(context, WorkerCertificatesPage());
                        },
                        child: Container(
                          margin:
                              EdgeInsets.only(left: AdapterUtils.getWidth(20)),
                          height: AdapterUtils.getHeight(80),
                          decoration: BoxDecoration(
                              border: Border(
                                  bottom: BorderSide(
                                      color: Color(0xffEEEEEE), width: 1))),
                          child: Row(
                            mainAxisAlignment: MainAxisAlignment.spaceBetween,
                            children: <Widget>[
                              Row(
                                children: <Widget>[
                                  Text(
                                    '我的证件',
                                    style: TextStyle(
                                      fontSize: AdapterUtils.getSp(16),
                                      color: Color(0xff141F33),
                                      fontWeight: FontWeight.w500,
                                    ),
                                  ),
                                  Text(
                                    '',
                                    style: TextStyle(
                                      fontSize: AdapterUtils.getSp(16),
                                      color: Color(0xffFF1515),
                                      fontWeight: FontWeight.w500,
                                    ),
                                  ),
                                ],
                              ),
                              Row(
                                children: <Widget>[
                                  Text(
                                    data['iszhengjian']==1?'已上传' :'请上传',
                                    style: TextStyle(
                                      fontSize: AdapterUtils.getSp(14),
                                      color: Color(0xffD7D8DB),
                                      fontWeight: FontWeight.w500,
                                    ),
                                  ),
                                  SizedBox(
                                    width: AdapterUtils.getWidth(20),
                                  ),
                                  Image.asset(AssetsUtils.getAssetsImagesPath(
                                      'arrow_right.png')),
                                  SizedBox(
                                    width: AdapterUtils.getWidth(20),
                                  )
                                ],
                              )
                            ],
                          ),
                        ),
                      ),
                      InkWell(
                        onTap: (){
                           Routes.navigateTo(context, WorkerEducationBackgroundPage());
                        },
                        child: Container(
                          margin:
                              EdgeInsets.only(left: AdapterUtils.getWidth(20)),
                          height: AdapterUtils.getHeight(80),
                          decoration: BoxDecoration(
                              border: Border(
                                  bottom: BorderSide(
                                      color: Color(0xffEEEEEE), width: 1))),
                          child: Row(
                            mainAxisAlignment: MainAxisAlignment.spaceBetween,
                            children: <Widget>[
                              Row(
                                children: <Widget>[
                                  Text(
                                    '教育背景',
                                    style: TextStyle(
                                      fontSize: AdapterUtils.getSp(16),
                                      color: Color(0xff141F33),
                                      fontWeight: FontWeight.w500,
                                    ),
                                  ),
                                  Text(
                                    '',
                                    style: TextStyle(
                                      fontSize: AdapterUtils.getSp(16),
                                      color: Color(0xffFF1515),
                                      fontWeight: FontWeight.w500,
                                    ),
                                  ),
                                ],
                              ),
                              Row(
                                children: <Widget>[
                                  Text(
                                    data['isjiaoyubeijing']==1?'已上传' :'请上传',
                                    style: TextStyle(
                                      fontSize: AdapterUtils.getSp(14),
                                      color: Color(0xffD7D8DB),
                                      fontWeight: FontWeight.w500,
                                    ),
                                  ),
                                  SizedBox(
                                    width: AdapterUtils.getWidth(20),
                                  ),
                                  Image.asset(AssetsUtils.getAssetsImagesPath(
                                      'arrow_right.png')),
                                  SizedBox(
                                    width: AdapterUtils.getWidth(20),
                                  )
                                ],
                              )
                            ],
                          ),
                        ),
                      ),
                      InkWell(
                        onTap: (){
                           Routes.navigateTo(context, WorkerExpePage());
                        },
                        child: Container(
                          margin:
                              EdgeInsets.only(left: AdapterUtils.getWidth(20)),
                          height: AdapterUtils.getHeight(80),
                          decoration: BoxDecoration(
                              border: Border(
                                  bottom: BorderSide(
                                      color: Color(0xffEEEEEE), width: 1))),
                          child: Row(
                            mainAxisAlignment: MainAxisAlignment.spaceBetween,
                            children: <Widget>[
                              Row(
                                children: <Widget>[
                                  Text(
                                    '工作经历',
                                    style: TextStyle(
                                      fontSize: AdapterUtils.getSp(16),
                                      color: Color(0xff141F33),
                                      fontWeight: FontWeight.w500,
                                    ),
                                  ),
                                  Text(
                                    ' ',
                                    style: TextStyle(
                                      fontSize: AdapterUtils.getSp(16),
                                      color: Color(0xffFF1515),
                                      fontWeight: FontWeight.w500,
                                    ),
                                  ),
                                ],
                              ),
                              Row(
                                children: <Widget>[
                                  Text(
                                    data['isgongzuojingli']==1?'已上传' :'请上传',
                                    style: TextStyle(
                                      fontSize: AdapterUtils.getSp(14),
                                      color: Color(0xffD7D8DB),
                                      fontWeight: FontWeight.w500,
                                    ),
                                  ),
                                  SizedBox(
                                    width: AdapterUtils.getWidth(20),
                                  ),
                                  Image.asset(AssetsUtils.getAssetsImagesPath(
                                      'arrow_right.png')),
                                  SizedBox(
                                    width: AdapterUtils.getWidth(20),
                                  )
                                ],
                              )
                            ],
                          ),
                        ),
                      ),
                      InkWell(
                        onTap: (){
                           Routes.navigateTo(context, WorkerFamilyPage());
                        },
                        child: Container(
                          margin:
                              EdgeInsets.only(left: AdapterUtils.getWidth(20)),
                          height: AdapterUtils.getHeight(80),
                          decoration: BoxDecoration(
                              border: Border(
                                  bottom: BorderSide(
                                      color: Color(0xffEEEEEE), width: 1))),
                          child: Row(
                            mainAxisAlignment: MainAxisAlignment.spaceBetween,
                            children: <Widget>[
                              Row(
                                children: <Widget>[
                                  Text(
                                    '家庭成员',
                                    style: TextStyle(
                                      fontSize: AdapterUtils.getSp(16),
                                      color: Color(0xff141F33),
                                      fontWeight: FontWeight.w500,
                                    ),
                                  ),
                                  Text(
                                    ' ',
                                    style: TextStyle(
                                      fontSize: AdapterUtils.getSp(16),
                                      color: Color(0xffFF1515),
                                      fontWeight: FontWeight.w500,
                                    ),
                                  ),
                                ],
                              ),
                              Row(
                                children: <Widget>[
                                  Text(
                                    data['isjiatingchengyuan']==1?'已上传' :'请上传',
                                    style: TextStyle(
                                      fontSize: AdapterUtils.getSp(14),
                                      color: Color(0xffD7D8DB),
                                      fontWeight: FontWeight.w500,
                                    ),
                                  ),
                                  SizedBox(
                                    width: AdapterUtils.getWidth(20),
                                  ),
                                  Image.asset(AssetsUtils.getAssetsImagesPath(
                                      'arrow_right.png')),
                                  SizedBox(
                                    width: AdapterUtils.getWidth(20),
                                  )
                                ],
                              )
                            ],
                          ),
                        ),
                      ),
                      InkWell(
                        onTap: () {
                          if (data['qiuzhiyixiangType']==0 || data['qiuzhiyixiangType']=='null') {
                            
                          }else if (data['qiuzhiyixiangType']=='qiuzhiyixiangType_GS') {
                            //公司员工
                            Routes.navigateTo(context, WorkerObjectCompanyPage());
                          }else if (data['qiuzhiyixiangType']=='qiuzhiyixiangType_GC') {
                            //工厂员工
                            Routes.navigateTo(context, WorkerObjectFactoryPage());
                          }
                        },
                        child: Container(
                          margin:
                              EdgeInsets.only(left: AdapterUtils.getWidth(20)),
                          height: AdapterUtils.getHeight(80),
                          decoration: BoxDecoration(
                              border: Border(
                                  bottom: BorderSide(
                                      color: Color(0xffEEEEEE), width: 1))),
                          child: Row(
                            mainAxisAlignment: MainAxisAlignment.spaceBetween,
                            children: <Widget>[
                              Row(
                                children: <Widget>[
                                  Text(
                                    '求职意向',
                                    style: TextStyle(
                                      fontSize: AdapterUtils.getSp(16),
                                      color: Color(0xff141F33),
                                      fontWeight: FontWeight.w500,
                                    ),
                                  ),
                                  Text(
                                    ' ',
                                    style: TextStyle(
                                      fontSize: AdapterUtils.getSp(16),
                                      color: Color(0xffFF1515),
                                      fontWeight: FontWeight.w500,
                                    ),
                                  ),
                                ],
                              ),
                              Row(
                                children: <Widget>[
                                  Text(
                                    data['isqiuzhiyixiang']==1?'已上传' :'请上传',
                                    style: TextStyle(
                                      fontSize: AdapterUtils.getSp(14),
                                      color: Color(0xffD7D8DB),
                                      fontWeight: FontWeight.w500,
                                    ),
                                  ),
                                  SizedBox(
                                    width: AdapterUtils.getWidth(20),
                                  ),
                                  Image.asset(AssetsUtils.getAssetsImagesPath(
                                      'arrow_right.png')),
                                  SizedBox(
                                    width: AdapterUtils.getWidth(20),
                                  )
                                ],
                              )
                            ],
                          ),
                        ),
                      ),
                      InkWell(
                        onTap: (){
                           Routes.navigateTo(context, WorkerEvaluatePage());
                        },
                        child: Container(
                          margin:
                              EdgeInsets.only(left: AdapterUtils.getWidth(20)),
                          height: AdapterUtils.getHeight(80),
                          decoration: BoxDecoration(
                              border: Border(
                                  bottom: BorderSide(
                                      color: Color(0xffEEEEEE), width: 1))),
                          child: Row(
                            mainAxisAlignment: MainAxisAlignment.spaceBetween,
                            children: <Widget>[
                              Row(
                                children: <Widget>[
                                  Text(
                                    '自我评价',
                                    style: TextStyle(
                                      fontSize: AdapterUtils.getSp(16),
                                      color: Color(0xff141F33),
                                      fontWeight: FontWeight.w500,
                                    ),
                                  ),
                                  Text(
                                    ' ',
                                    style: TextStyle(
                                      fontSize: AdapterUtils.getSp(16),
                                      color: Color(0xffFF1515),
                                      fontWeight: FontWeight.w500,
                                    ),
                                  ),
                                ],
                              ),
                              Row(
                                children: <Widget>[
                                  Text(
                                    data['isziwopingjia']==1?'已上传' :'请上传',
                                    style: TextStyle(
                                      fontSize: AdapterUtils.getSp(14),
                                      color: Color(0xffD7D8DB),
                                      fontWeight: FontWeight.w500,
                                    ),
                                  ),
                                  SizedBox(
                                    width: AdapterUtils.getWidth(20),
                                  ),
                                  Image.asset(AssetsUtils.getAssetsImagesPath(
                                      'arrow_right.png')),
                                  SizedBox(
                                    width: AdapterUtils.getWidth(20),
                                  )
                                ],
                              )
                            ],
                          ),
                        ),
                      ),
                      SizedBox(
                        height: AdapterUtils.getHeight(47),
                      ),
                      Container(
                          width: AdapterUtils.screenWidth(),
                          height: AdapterUtils.getHeight(50),
                          margin: EdgeInsets.all(15),
                          child: FlatButton(
                              onPressed: () {},
                              disabledColor: Color(0xff15A1FF).withAlpha(80),
                              color: Color(0xff15A1FF),
                              shape: RoundedRectangleBorder(
                                borderRadius:
                                    BorderRadius.all(Radius.circular(4)),
                              ),
                              child: Text(
                                '回到首页',
                                style: TextStyle(
                                  fontSize: AdapterUtils.getSp(16),
                                  color: Colors.white,
                                  fontWeight: FontWeight.w500,
                                ),
                              ))),
                    ],
                  ),
                )),
    );
  }

  Widget _loadingWidget() {
    return Center(
      child: CupertinoActivityIndicator(
        animating: true,
        radius: 20,
      ),
    );
  }

  void requestApi() {
    Http.instance.post('app/call/getusers_info_gr', null, onSuccess: (data) {
      if (mounted) {
        setState(() {
          this.data=data;
        });
      }
    }, onError: (error) {}, onFail: (fail) {});
  }
}
